package com.lyl.service.impl;

import com.lyl.domain.SysMenu;
import com.lyl.mapper.SysMenuMapper;
import com.lyl.mapper.SysRoleMapper;
import com.lyl.service.SysMenuService;
import com.lyl.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;


/**
 * @author lylbell
 * @date 2021-06-22 13:31
 */
    
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {

    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Autowired
    private SysRoleService sysRoleService;


    /**
     * 通过用户id查询用户菜单
     * @param userId
     * @return
     */
    @Override
    public List<SysMenu> getMenusByUserId(Long userId) {
        //1、判断该用户是不是超级管理员
        if (sysRoleService.isSuperAdmin(userId)) {
            return list();
        }
        //2、不是超级管理员-->查询角色-->查询菜单
        return sysMenuMapper.getMenusByUserId(userId);
    }
}
